package tech.aistar.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.pojo.Product;

import java.util.List;

public interface ProductMapper {
    @Select("select * from product where product_id = #{value}")
    Product findById(Integer id);

    @Delete("delete from product where product_id = #{id}")
    int delById(Integer id);

    @Insert("insert into product(product_name, category_id, price, stock, description, seller_id, status, create_time, update_time,pimgUrl) " +
            "values(#{productName}, #{categoryId}, #{price}, #{stock}, #{description}, #{sellerId}, #{status}, #{createTime}, #{updateTime},#{pimgUrl})")
    int insertProduct(Product product);

    @Update("update product set product_name=#{productName}, category_id=#{categoryId}, price=#{price}, stock=#{stock}, " +
            "description=#{description}, seller_id=#{sellerId}, status=#{status}, update_time=#{updateTime},pimgUrl=#{pimgUrl} where product_id=#{productId}")
    int updateProduct(Product product);

    @Select("select * from product")
    List<Product> findAll();

}